package com.yyfax.ph.personal.mymoney.cash;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.aspsine.irecyclerview.IViewHolder;
import com.yyfax.common.recyclerview.BaseRecycleAdapter;
import com.yyfax.ph.R;
import com.yyfax.ph.common.utils.FormatUtils;

/**
 * Created by xiongyufeng on 2017/11/11.
 * Copyright  2017 www.yylending.com. All Rights Reserved.
 */
public class RebateDetailAdapter extends BaseRecycleAdapter<RebateDetailModel.RebateInfo> {
	@Override
	public IViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rebate_item, null);
		return new ViewHolder(view);
	}

	@Override
	public void onBindViewHolder(IViewHolder holder, int position) {
		ViewHolder viewHolder = (ViewHolder) holder;
		RebateDetailModel.RebateInfo bean = getDataSet().get(position);
		viewHolder.dateTv.setText(bean.operateDate);
		viewHolder.borrowerTv.setText(bean.customerName);
		viewHolder.lendingAmountTv.setText(FormatUtils.getDecoratedAmount(bean.businesssum));
		viewHolder.rebateAmountTv.setText(FormatUtils.getFormatMoney(bean.amount));
	}

	@Override
	public int getItemCount() {
		return getCount();
	}


	static class ViewHolder extends IViewHolder {
		@BindView(R.id.borrower_tv)
		TextView borrowerTv;
		@BindView(R.id.date_tv)
		TextView dateTv;
		@BindView(R.id.lending_amount_tv)
		TextView lendingAmountTv;
		@BindView(R.id.rebate_amount_tv)
		TextView rebateAmountTv;

		ViewHolder(View view) {
			super(view);
			ButterKnife.bind(this, view);
		}
	}
}
